package com.rd.student.dashuju.wangbo.exercise0728;

public class TestThreadLocal {

    static ThreadLocal<String> local = new ThreadLocal<>();

    public static void main (String[] args) {

        new Thread(new Runnable() {
            @Override
            public void run() {
                local.set("A");
                System.out.println(local.get());
                local.remove();
                System.out.println("移除元素A");
            }
        },"A").start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                local.set("B");
                System.out.println(local.get());
                local.remove();
                System.out.println("移除元素B");
            }
        },"B").start();
    }
}
